package 统计字符;

/**
 * @author Administrator
 * @ClassName Statistics
 * @TIME 星期五 2020/12/25
 */
public class Statistics extends Thread {
    @Override
    public void run() {
        String str = "123 , ABC abc @ : %^&* < > { ] = +";
        //存放字母
        StringBuilder letter = new StringBuilder();
        //存放数字
        StringBuilder num = new StringBuilder();
        //存放字符
        StringBuilder ch = new StringBuilder();
        //存放 空格
        StringBuilder nulls = new StringBuilder();

        for (int i = 0; i < str.length(); i++) {
            char chars = str.charAt(i);
            if (chars >= 48 && chars <= 57) {
                num.insert(0, chars);
            }
            if (chars >= 65 && chars <= 90 || chars >= 97 && chars <= 122) {
                letter.insert(0, chars);
            }
            if (chars >= 33 && chars <= 47 || chars >= 58 && chars <= 64 || chars >= 123 && chars <= 126 || chars >= 91 && chars <= 96) {
                ch.insert(0, chars);
            }
            //空格
            if (chars == 32){
                nulls.insert(0,chars);
            }
        }
        System.out.println("数字 :" + num);
        System.out.println("字符 :" + letter);
        System.out.println("符号 :" + ch);
        System.out.println("空格 :" + nulls + "/");
    }

    public static void main(String[] args) {
        Statistics s = new Statistics();
        s.start();
    }
}
